package com.personal.common.bean;

import java.util.List;

@SuppressWarnings("rawtypes")
public class PageUtil {

	public static final PageUtil EMPTY_PAGE = new PageUtil() {

		public int getTotalPageCount() {
			return 0;
		}

	};
	/** 状态码 */
	private int code = 0;//0
	
	/** 当前页的大小 */
	private String msg = "成功";//提示
	
	/** 当前页的大小 */
	private int pageSize;

	/** 总共的条数 */
	private Integer count;

	/** 当前页 */
	private int pageNo;

	/** 分页数据 */
	private List data;

	/** 多少页 */
	private Integer pageCount;

	public PageUtil() {
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNo() {
		return pageNo;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public List getData() {
		return data;
	}

	public void setData(List data) {
		this.data = data;
	}

	public Integer getPageCount() {
		return pageCount;
	}

	public void setPageCount(Integer pageCount) {
		this.pageCount = pageCount;
	}

	public int getTotalPageCount() {
		return (getCount() - 1) / getPageSize() + 1;
	}

	public boolean hasNextPage() {
		return getPageNo() < getTotalPageCount();
	}

	public boolean hasPreviousPage() {
		return getPageNo() > 1;
	}

	public boolean isEmpty() {
		return this == EMPTY_PAGE;
	}

}
